package com.ts.main.admin.service;

import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.ts.main.admin.dto.MiniUserDto;
import com.ts.main.admin.dto.MiniUserSearchPageDto;
import com.ts.main.admin.entity.UserEntity;
import com.ts.main.admin.exception.RPage;
import com.ts.main.admin.mapper.UserMapper;
import com.ts.main.admin.vo.AdminRolePartVo;
import com.ts.main.admin.vo.MiniUserVo;
import jakarta.annotation.Resource;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author lk
 * @description 针对表【t_user(用户表)】的数据库操作Service实现
 * @createDate 2025-06-09 00:56:13
 */
@AllArgsConstructor
@Service
public class UserServiceImpl extends ServiceImpl<UserMapper, UserEntity> {

    private final RoleServiceImpl roleServiceImpl;

    public RPage<List<MiniUserVo>> getMiniUserPage(MiniUserSearchPageDto dto) {
        Page<Object> page = PageHelper.startPage(dto.getPage(), dto.getLimit());
        List<MiniUserVo> list = baseMapper.getMiniUserPage(dto);
        return RPage.ok(list, dto.getPage(), dto.getLimit(), page.getTotal());
    }

    public MiniUserVo getMiniUserDetails(Integer userId) {
        return baseMapper.getMiniUserDetails(userId);
    }

    public List<AdminRolePartVo> getRoleList() {
        return roleServiceImpl.getRoleList();
    }

}




